<?php 
	
class pays {
	
	private $idPays ;   
	private $nom;
	private $nationalite ;
	private $adresseImage ; 

	
	public function __construct()
	{
		$this->db = new myPdo ;
		$req="set names 'UTF8'";
		$this->db->exec($req);
	}
	
	// SETTEURS
	public function setIdPays($idPays) 
	{
		$this->idPays = $idPays ;
	}
	public function setNom($nom) 
	{
		$this->nom = $nom ;
	}
	public function setNationalite($nationalite) 
	{
		$this->nationalite = $nationalite  ;
	}
	public function setAdresseImage($adresseImage) 
	{
		$this->adresseImage = $adresseImage ;
	}
	
	
	// GETTEURS
	public function getIdPays() 
	{
		return $this->idPays;
	}
	public function getNom() 
	{
		return $this->nom;
	}
	public function getNationalite() 
	{
		return $this->nationalite;
	}
	public function getAdressePays() 
	{
		return $this->adressePays;
	}

	
	public function getAllNationalites()
	{
		$r = "  SELECT PAYNUM, PAYNAT FROM pays ORDER BY PAYNAT ;";
            
		$resu = $this->db->query($r) ;
		
		while ($ligne = $resu->fetch(PDO::FETCH_OBJ))
		{
			$tablo[] = $ligne ;
		}
		return $tablo ;
	}
	
	public function getAllPays()
	{
		$r = "  SELECT PAYNUM, PAYNOM FROM pays ORDER BY PAYNOM ;";
            
		$resu = $this->db->query($r) ;
		
		while ($ligne = $resu->fetch(PDO::FETCH_OBJ))
		{
			$tablo[] = $ligne ;
		}
		return $tablo ;
	}
	
	public function remplirPays()
	{
		$r = "SELECT PAYNUM, PAYNOM, PAYNAT, PAYADRDRAP FROM pays WHERE PAYNUM = '$this->idPays' ; " ;
		$resu = $this->db->query($r) ;
		
		$ligne = $resu->fetch(PDO::FETCH_OBJ) ;
		
		$this->nom = $ligne->PAYNOM ;
		$this->nationalite = $ligne->PAYNAT ;
		$this->adressePays = $ligne->PAYADRDRAP ;
		
		//$this->adresse = $resu->fetch(PDO::FETCH_OBJ)->PHOADRESSE ;
	}
	public function getPaysByGP()
	{
		$r = "SELECT PAYADRDRAP FROM pays WHERE PAYNUM =".$this->idPays." ; " ;
		echo $r ;
		$resu = $this->db->query($r) ;
		$ligne = $resu->fetch(PDO::FETCH_OBJ) ;
		$this->adresseImage = $ligne->PAYADRDRAP ;
	}
	
	
}
?>